Skip to content

feat: add separate tsconfig for test files#4616

Merged
arkid15r merged 9 commits intoOWASP:mainfrom
devnchill:fix/import
May 9, 2026
Merged

feat: add separate tsconfig for test files#4616
arkid15r merged 9 commits intoOWASP:mainfrom
devnchill:fix/import

Conversation

@devnchill
Copy link
Copy Markdown
Contributor

Proposed change

Resolves #4571

Add the PR description here.

tsconfig in frontend/tsconfig.json excludes test directory. this causes for lsp unable to pick up any globals/methods from jest libraries . This pr adds a separate tsconfig.json in frontend/__tests__ .

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Review Change Stack

Warning

Rate limit exceeded

@arkid15r has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 51 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cfea255a-beae-45d4-a803-76f627177700

📥 Commits

Reviewing files that changed from the base of the PR and between 2b177dd and 5d280c7.

📒 Files selected for processing (10)
  • frontend/__tests__/a11y/components/RepositoryCard.a11y.test.tsx
  • frontend/__tests__/unit/components/CardDetailsPage.test.tsx
  • frontend/__tests__/unit/components/ContributionStats.test.tsx
  • frontend/__tests__/unit/components/ContributorAvatar.test.tsx
  • frontend/__tests__/unit/components/ItemCardList.test.tsx
  • frontend/__tests__/unit/components/MentorshipPullRequest.test.tsx
  • frontend/__tests__/unit/components/ModuleCard.test.tsx
  • frontend/__tests__/unit/components/RecentIssues.test.tsx
  • frontend/__tests__/unit/components/RepositoryCard.test.tsx
  • frontend/__tests__/unit/components/SnapshotCard.test.tsx

Walkthrough

Adds a test-scoped TypeScript config at frontend/__tests__/tsconfig.json, moves Jest setup into __tests__/jest.setup.ts, updates the frontend test script and devDependencies (removes ts-jest, adds @testing-library/dom), refines Docker COPY steps and pre-commit exclusions, and normalizes many accessibility and unit test fixtures and typings to use ISO-8601 date strings.

Changes

Frontend tests & CI wiring

Layer / File(s) Summary
TypeScript & Jest config
frontend/__tests__/tsconfig.json, frontend/jest.config.ts, frontend/tsconfig.json
Add test-scoped tsconfig extending root, declare jest/@testing-library/node types, set noEmit/isolatedModules; update Jest setupFilesAfterEnv to __tests__/jest.setup.ts and add it to testPathIgnorePatterns; stop excluding jest.setup.ts in frontend tsconfig.
Pre-commit hook
.pre-commit-config.yaml
Add exclude regex for check-json to ignore JSONC tsconfig.json files under frontend/.
Docker test images
docker/frontend/Dockerfile.unit.test, docker/frontend/Dockerfile.a11y.test
Make Docker COPY steps explicit: copy __tests__/jest.setup.ts and __tests__/tsconfig.json into images; avoid copying repo-root jest.setup.ts.
Package / DevDependencies & scripts
frontend/package.json
test:unit now runs tsc --noEmit -p __tests__/tsconfig.json before Jest; remove ts-jest, add @testing-library/dom, and change eslint devDependency version.
Accessibility tests (fixtures & props)
frontend/__tests__/a11y/components/*
Normalize mocked timestamps to ISO strings, make release timestamps deterministic, add/remove render props (entityKey, remove login), and use ExperienceLevelEnum in ModuleCard fixture.
Unit tests (fixtures & types)
frontend/__tests__/unit/**, frontend/__tests__/unit/utils/*
Convert many mock timestamps to ISO strings, add title to ICS fixtures, adjust SnapshotCard coercions and ItemCardList/HealthMetrics typing, and narrow a literal prop type in a CardDetailsPage test.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • OWASP/Nest#3864: Related relocation/addition of many frontend tests and test wiring adjustments.
  • OWASP/Nest#3857: Overlapping timestamp format conversions and test updates.
  • OWASP/Nest#4549: Changes to frontend jest/package/config files and pre-commit updates.

Suggested labels

docker, ci

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add separate tsconfig for test files' accurately summarizes the main change in the PR.
Description check ✅ Passed The description explains that the PR adds a separate tsconfig.json for test files to resolve LSP issues with Jest/testing-library globals.
Linked Issues check ✅ Passed The PR successfully addresses issue #4571 by creating frontend/tests/tsconfig.json to include test files and their typings.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving issue #4571: test files update timestamps to ISO strings, configuration files are adjusted to reference new test tsconfig locations, and build files are updated accordingly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@devnchill devnchill marked this pull request as ready for review May 6, 2026 19:37
@devnchill devnchill requested review from arkid15r and kasya as code owners May 6, 2026 19:37
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/__tests__/tsconfig.json`:
- Around line 4-8: Remove the "@testing-library/jest-dom" entry from the
tsconfig "types" array because it causes TS2688 with v6+; instead rely on the
import in jest.setup.ts (configured via setupFilesAfterEnv) which already
provides the globals, so edit the "types" array to omit
"@testing-library/jest-dom" and keep "jest" and "node" intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b0529400-fc0b-489b-b564-5cc6f7b34469

📥 Commits

Reviewing files that changed from the base of the PR and between 45ebaf5 and f3b8948.

📒 Files selected for processing (1)
  • frontend/__tests__/tsconfig.json

Comment thread frontend/__tests__/tsconfig.json Outdated
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes May 6, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@devnchill
Copy link
Copy Markdown
Contributor Author

@arkid15r , at the moment the jest scripts in frontend/package.json uses tsconfig.json file in frontend/tsconfig.json ,

    "test:a11y": "NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest __tests__/a11y/ --coverage=false",
    "test:unit": "tsc --noEmit && NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest"

however i was wondering that since tests now have their separate tsconfig, maybe i should provide this as config file for those test ?

@devnchill devnchill marked this pull request as draft May 6, 2026 19:43
@devnchill devnchill marked this pull request as ready for review May 6, 2026 20:00
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes May 6, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 7, 2026
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes May 7, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

@arkid15r
Copy link
Copy Markdown
Collaborator

arkid15r commented May 8, 2026

@arkid15r , at the moment the jest scripts in frontend/package.json uses tsconfig.json file in frontend/tsconfig.json ,

    "test:a11y": "NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest __tests__/a11y/ --coverage=false",
    "test:unit": "tsc --noEmit && NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest"

however i was wondering that since tests now have their separate tsconfig, maybe i should provide this as config file for those test ?

Yes, I think it'd be structurally better approach. Just make sure it's all backward compatible.

Thanks!

@devnchill
Copy link
Copy Markdown
Contributor Author

Alright 👍

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 9, 2026
@devnchill
Copy link
Copy Markdown
Contributor Author

devnchill commented May 9, 2026

swc jset uses config object inlined with transform or .swcrc so it does not seems to rely on frontend/tsconfig.json so Ig I don't need to specify the tsconfig file for running jest related scripts

cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes May 9, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Copy link
Copy Markdown
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update and merge this PR soon, please don't add any changes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main issue with the PR (your approach actually) it's that you don't follow the contribution workflow even though you marked the relevant checkbox 🤷‍♂️

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions Bot added the docker Pull requests that update Docker code label May 9, 2026
@arkid15r arkid15r enabled auto-merge May 9, 2026 19:41
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.92%. Comparing base (ff85a9b) to head (5d280c7).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4616   +/-   ##
=======================================
  Coverage   98.92%   98.92%           
=======================================
  Files         527      527           
  Lines       16956    16956           
  Branches     2360     2412   +52     
=======================================
  Hits        16774    16774           
  Misses         97       97           
  Partials       85       85           
Flag Coverage Δ
backend 99.50% <ø> (ø)
frontend 97.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff85a9b...5d280c7. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

coderabbitai[bot]
coderabbitai Bot previously requested changes May 9, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/__tests__/a11y/components/RecentPullRequests.a11y.test.tsx`:
- Around line 56-57: The test fixture in RecentPullRequests.a11y.test.tsx has an
inconsistent PR object with state: 'open' but a mergedAt timestamp; update the
fixture to be realistic by either setting state to 'merged' (so mergedAt remains
valid) or removing the mergedAt field if the PR should be open—locate the PR
object in the RecentPullRequests.a11y.test.tsx test case and adjust the state or
mergedAt accordingly to keep the fixture consistent with GraphQL DateTime ISO
string conventions.

In `@frontend/__tests__/a11y/components/SingleModuleCard.a11y.test.tsx`:
- Around line 60-61: The fixture mockModule uses startedAt as a numeric Unix
timestamp while endedAt is an ISO string; update startedAt to an ISO 8601 string
to match endedAt (e.g., new Date(1704067200 * 1000).toISOString()) so both
timestamp fields use the same type expected by the Module/GraphQL DateTime
serialization; ensure you update any tests that rely on numeric timestamps to
use the ISO string form as well.

In `@frontend/__tests__/unit/components/SingleModuleCard.test.tsx`:
- Around line 113-114: The test fixture in SingleModuleCard.test.tsx uses mixed
date formats: startedAt is a numeric Unix timestamp while endedAt is an ISO
string; update the fixture so both DateTime fields are ISO 8601 strings (e.g.,
set startedAt to new Date(1704067200 * 1000).toISOString() or an equivalent ISO
string) so startedAt and endedAt are consistent with GraphQL DateTime
serialization and the component's runtime expectations.

In `@frontend/__tests__/unit/components/SnapshotCard.test.tsx`:
- Around line 52-60: The test is using "0 as unknown as string" to simulate
missing dates which hides intent; update the two calls to render/rerender of
SnapshotCard to pass an explicit missing sentinel (prefer undefined or null,
e.g. startAt={undefined} and endAt={undefined}) instead of the type-coerced 0,
keeping the same asserts; if TypeScript complaints, adjust the test props by
casting only the prop (e.g. startAt={undefined as unknown as string} or widen
defaultProps type) so you change lines that set startAt/endAt in the render and
rerender calls for SnapshotCard and leave formatDate and expectations unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 92e7be3c-7abd-4093-9254-f8ac70f555d1

📥 Commits

Reviewing files that changed from the base of the PR and between 2671ac1 and 2b177dd.

⛔ Files ignored due to path filters (1)
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (29)
  • .pre-commit-config.yaml
  • docker/frontend/Dockerfile.a11y.test
  • docker/frontend/Dockerfile.unit.test
  • frontend/__tests__/a11y/components/CardDetailsPage.a11y.test.tsx
  • frontend/__tests__/a11y/components/LeadersList.a11y.test.tsx
  • frontend/__tests__/a11y/components/MentorshipPullRequest.a11y.test.tsx
  • frontend/__tests__/a11y/components/ModuleCard.a11y.test.tsx
  • frontend/__tests__/a11y/components/ProgramCard.a11y.test.tsx
  • frontend/__tests__/a11y/components/RecentPullRequests.a11y.test.tsx
  • frontend/__tests__/a11y/components/RecentRelease.a11y.test.tsx
  • frontend/__tests__/a11y/components/RecentReleases.a11y.test.tsx
  • frontend/__tests__/a11y/components/Release.a11y.test.tsx
  • frontend/__tests__/a11y/components/RepositoryCard.a11y.test.tsx
  • frontend/__tests__/a11y/components/SingleModuleCard.a11y.test.tsx
  • frontend/__tests__/a11y/components/ToggleableList.a11y.test.tsx
  • frontend/__tests__/jest.setup.ts
  • frontend/__tests__/tsconfig.json
  • frontend/__tests__/unit/components/CardDetailsPage.test.tsx
  • frontend/__tests__/unit/components/HealthMetrics.test.tsx
  • frontend/__tests__/unit/components/ItemCardList.test.tsx
  • frontend/__tests__/unit/components/RecentRelease.test.tsx
  • frontend/__tests__/unit/components/Release.test.tsx
  • frontend/__tests__/unit/components/RepositoryCard.test.tsx
  • frontend/__tests__/unit/components/SingleModuleCard.test.tsx
  • frontend/__tests__/unit/components/SnapshotCard.test.tsx
  • frontend/__tests__/unit/utils/getIcsFileUrl.test.ts
  • frontend/jest.config.ts
  • frontend/package.json
  • frontend/tsconfig.json
💤 Files with no reviewable changes (1)
  • frontend/tests/unit/components/HealthMetrics.test.tsx

Comment thread frontend/__tests__/a11y/components/RecentPullRequests.a11y.test.tsx
Comment thread frontend/__tests__/a11y/components/SingleModuleCard.a11y.test.tsx
Comment thread frontend/__tests__/unit/components/SingleModuleCard.test.tsx
Comment thread frontend/__tests__/unit/components/SnapshotCard.test.tsx
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes May 9, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 30 files (changes from recent commits).

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 10 files (changes from recent commits).

@arkid15r arkid15r added this pull request to the merge queue May 9, 2026
Merged via the queue into OWASP:main with commit 2685eff May 9, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Pull requests that update Docker code frontend frontend-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix import in multiple test files

2 participants